package com.yuan.plugin.adtool;

import android.content.Context;
import android.content.SharedPreferences;

public class P {

	public static final String PREFERENCESNAME = "test";
	public static final int PREFERENCESMODE = 0;
	public static final String SKEY = "skey";
	public static final String Mobile = "mobile";
	public static final String Active = "active";
	public static final String DoctorId = "doctorid";
	public static final String DoctorSex = "doctorSex";
	public static final String DoctorMobile = "doctormobile";
	public static final String DoctorAbout = "doctorabout";
	public static final String DoctorCheck = "doctorcheck";
	public static final String DoctorName = "doctorname";
	public static final String DoctorActive = "doctoractive";
	public static final String DoctorAddress = "doctoraddress";
	public static final String DoctorPhoto = "doctorphoto";
	public static final String KeepLogin = "keeplogin";
	public static void saveString(Context context, String key, String value) {
		try {
			SharedPreferences preferences = context.getApplicationContext()
					.getSharedPreferences(PREFERENCESNAME, PREFERENCESMODE);
			preferences.edit().putString(key, value).commit();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static String getString(Context context, String key) {
		SharedPreferences preferences = context.getSharedPreferences(
				PREFERENCESNAME, PREFERENCESMODE);
		return preferences.getString(key, null);
	}

	public static void saveInt(Context context, String key, int value) {
		SharedPreferences preferences = context.getSharedPreferences(
				PREFERENCESNAME, PREFERENCESMODE);
		preferences.edit().putInt(key, value).commit();
	}

	public static int getInt(Context context, String key) {
		SharedPreferences preferences = context.getSharedPreferences(
				PREFERENCESNAME, PREFERENCESMODE);
		return preferences.getInt(key, 0);
	}

	public static void saveLong(Context context, String key, long value) {
		SharedPreferences preferences = context.getSharedPreferences(
				PREFERENCESNAME, PREFERENCESMODE);
		preferences.edit().putLong(key, value).commit();
	}

	public static long getLong(Context context, String key) {
		SharedPreferences preferences = context.getSharedPreferences(
				PREFERENCESNAME, PREFERENCESMODE);
		return preferences.getLong(key, 0);
	}

	public static void saveFloat(Context context, String key, float value) {
		SharedPreferences preferences = context.getSharedPreferences(
				PREFERENCESNAME, PREFERENCESMODE);
		preferences.edit().putFloat(key, value).commit();
	}

	public static float getFloat(Context context, String key) {
		SharedPreferences preferences = context.getSharedPreferences(
				PREFERENCESNAME, PREFERENCESMODE);
		return preferences.getFloat(key, 0);
	}

	public static void saveBool(Context context, String key, boolean value) {
		SharedPreferences preferences = context.getSharedPreferences(
				PREFERENCESNAME, PREFERENCESMODE);
		preferences.edit().putBoolean(key, value).commit();
	}

	public static boolean getBool(Context context, String key) {
		SharedPreferences preferences = context.getSharedPreferences(
				PREFERENCESNAME, PREFERENCESMODE);
		return preferences.getBoolean(key, false);
	}
}
